﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows;
using DoodJetView.Core.Reservation;

namespace DoodJetView.VuesPartielles
{
    public class DynamicGridResultat
    {
        public DynamicGridResultat(Grid view) 
        {
            this.View = view;


            this.GridRes = new DynamicGridTools(view.RenderSize.Width, true);

            this.SpecifieBesoinGrille();
        }
       

        private void SpecifieBesoinGrille()
        {
            this.GridRes.CreateColumn(60);

            this.GridRes.CreateRow(65);
            this.GridRes.CreateRow(65);
            this.GridRes.CreateRow(65);

            this.GridRes.CreateTextBlock("Salut", 1, 1);
            /*this.GridRes.AddUiToCase(new PartialDayOfActivities("test"),0,0);
            this.GridRes.AddUiToCase(new PartialDayOfActivities("test 2"), 1, 0);
            this.GridRes.AddUiToCase(new PartialDayOfActivities("test 3"), 2, 0);*/
            
        }
        public void Render() 
        {
            this.View.Children.Clear();
            this.View.Children.Add(
            this.GridRes.Render()); 
            
        }
        
        public Grid View { get; set; }
        public DynamicGridTools GridRes { get; set; }
    }
    public class DynamicGridTools : IDisposable
    {
        private bool p;
        private int p_2;
        private bool p_3;
        private ReservationCreation reservationCreation;
        private double p_4;
        private bool p_5;

        public DynamicGridTools(double width, bool ShowGridLines) 
        {
            // Create the Grid

            DynamicGrid = new Grid();

            DynamicGrid.Width = width;

            DynamicGrid.HorizontalAlignment = HorizontalAlignment.Stretch;

            DynamicGrid.VerticalAlignment = VerticalAlignment.Stretch;

            DynamicGrid.ShowGridLines = ShowGridLines;

         //   DynamicGrid.Background = new SolidColorBrush(Colors.LightSteelBlue);
        }

        public DynamicGridTools(int width, bool ShowGridLines, ReservationCreation reservationCreation)
        {
            // Create the Grid

            this.reservationCreation = reservationCreation;
            DynamicGrid = new Grid();

            DynamicGrid.Width = width;

            DynamicGrid.HorizontalAlignment = HorizontalAlignment.Stretch;

            DynamicGrid.VerticalAlignment = VerticalAlignment.Stretch;

            DynamicGrid.ShowGridLines = ShowGridLines;
        }

        public DynamicGridTools(double width, bool ShowGridLines, ReservationCreation reservationCreation)
        {
            this.reservationCreation = reservationCreation;
            DynamicGrid = new Grid();

            DynamicGrid.Width = width;

            DynamicGrid.HorizontalAlignment = HorizontalAlignment.Stretch;

            DynamicGrid.VerticalAlignment = VerticalAlignment.Stretch;

            DynamicGrid.ShowGridLines = ShowGridLines;
        }

      

        public Grid DynamicGrid { get; set; }

        public TextBlock CreateTextBlock(string text, int RowId, int ColumnId)
        {
            TextBlock txtBlock1 = new TextBlock();

            txtBlock1.Text = text;

            txtBlock1.FontSize = 14;

            txtBlock1.FontWeight = FontWeights.Bold;

            txtBlock1.Foreground = new SolidColorBrush(Colors.Black);

            txtBlock1.VerticalAlignment = VerticalAlignment.Top;
            AddUiToCase(txtBlock1, RowId, ColumnId);
            return txtBlock1;
        }

        public void AddUiToCase(UIElement UiElement, int Row, int Col)
        {
            this.DynamicGrid.Children.Add(UiElement);
            Grid.SetRow(UiElement, Row);
            Grid.SetColumn(UiElement, Col);
        }
        public void CreateRow()
        {
            RowDefinition gridRow3 = new RowDefinition();
            gridRow3.Height = new GridLength();
            DynamicGrid.RowDefinitions.Add(gridRow3);
        }
        public void CreateRow(int Height)
        {
            RowDefinition gridRow3 = new RowDefinition();
            gridRow3.MinHeight = Height;
            DynamicGrid.RowDefinitions.Add(gridRow3);
        }
        public void CreateColumn()
        {
            ColumnDefinition gridCol1 = new ColumnDefinition();

            DynamicGrid.ColumnDefinitions.Add(gridCol1);
        }
        public void CreateColumn(int minWidth)
        {
            ColumnDefinition gridCol1 = new ColumnDefinition();
            //gridCol1
           // gridCol1.MinWidth = minWidth;
            DynamicGrid.ColumnDefinitions.Add(gridCol1);
        }
        public void Render(Grid DestinationGrid)
        {
            DestinationGrid.Children.Add(this.DynamicGrid);

        }

        public Grid Render()
        {
           return this.DynamicGrid;

        }
        
        public void Dispose()
        {
         //   throw new NotImplementedException();
        }



        internal void Reset()
        {
            this.DynamicGrid.Children.Clear();
            
        }
    }
}
